*Rename "Durationinseconds" to "time"
ren Durationinseconds time

**Running this do file's routines to convert string variables requires installing the strrec command (ssc install strrec)

*Assign numeric values to strings with labels 

strrec Q3 ("Asian/Oceania"=1 "Non-Hispanic Asian or Pacific Islander") ("Black/African American"=2 "Non-Hispanic Black")  ("Hispanic/Latino"=3 "Hispanic") ("Native American/Indian"=4 "Non-Hispanic American Indian or Alaska Native") ("Other" = 5) ("White/European"=6 "Non-Hispanic, White")("Black/African American,Native American/Indian"=7 "Non-Hispanic Multiracial/Other") ("Black/African American,White/European"=7 "Non-Hispanic Multiracial/Other") ("Native American/Indian,White/European"=7 "Non-Hispanic Multiracial/Other")("White/European,Other"=7) ("Asian/Oceania,White/European"=7 "Non-Hispanic Multiracial/Other")  ("White/European,Other"=7 "Non-Hispanic Multiracial/Other") ("Asian/Oceania,Black/African American,Hispanic/Latino"=8 "Hispanic/Multiracial/Other")  ("Asian/Oceania,Hispanic/Latino,White/European"=8 "Hispanic/Multiracial/Other") ("Black/African American,Hispanic/Latino"=8 "Hispanic/Multiracial/Other") ("Black/African American,Hispanic/Latino,White/European"=8 "Hispanic/Multiracial/Other") ("Hispanic/Latino,Native American/Indian"=8 "Hispanic/Multiracial/Other") ("Hispanic/Latino,Native American/Indian,White/European"=8 "Hispanic/Multiracial/Other") ("Hispanic/Latino,Other"=8 "Hispanic/Multiracial/Other") ("Hispanic/Latino,White/European"=8 "Hispanic/Multiracial/Other"), sub generate(q3) 
label variable q3 "Racial/Ethnic Background"

strrec Q4 ("18 to 24 years old"=1) ("25 to 34 years old"=2) ("35 to 44 years old"=3) ("45 to 64 years old"=4) ("65+ years old"=5) (.=.), sub generate(q4)
label variable q4 "Age"

strrec Q5 ("Female"=3) ("Male"=2) ("Other"=1) (.=.), sub generate(q5)
label variable q5 "Sex"

strrec Q6 ("Less than a high school degree"=0) ("High school degree or equivalent (e.g., GED [General Education Development])"=1) ("Some college"=2) ("Associate's degree"=3) ("Bachelor's degree" =4) ("Master's degree"=5) ("Terminal Degree (e.g., Ph.D., M.D.)" =6) (.=.), sub generate(q6)
label variable q6 "Education"

strrec Q7 ("Not employed, NOT looking for work"=0) ("Not employed, looking for work"=1) ("Disabled, not able to work"=2) ("Retired"=3) ("Employed, working 1 to 39 hours per week"=4) ("Employed, working 40 or more hours per week"=5) (.=.), sub generate(q7)
label variable q7 "Employment Status"

strrec Q8 ("Less than $25,000"=1) ("$25,000 to $34,999"=2) ("$35,000 to $49,999"=3) ("$50,000 to $74,999"=4) ("$75,000 to $99,999"=5) ("$100,000 to $149,999"=6) ("$150,000 to $249,999"=7) ("$250,000+"=8) (.=.), sub generate(q8)
label variable q8 "Income"

strrec Q10 ("Rural"=1)("Suburban"=2)("Urban"=3)(.=.), sub generate(q10)
label variable q10 "Residency Area Type"

strrec Q11 ("Strong Democrat"=1)("Weak Democrat"=2)("Leaning Democartic"=3)("Independent"=4)("Leaning Republican"=5)("Weak Republican"=6)("Strong Republican"=7)(.=.), sub generate(q11)
label variable q11 "Partisan ID"

strrec Q12 ("Extremely liberal"=1)("Liberal"=2)("Slightly liberal"=3)("Moderate"=4)("Slightly conservative"=5)("Conservative"=6)("Extremely conservative"=7)(.=.), sub generate(q12)
label variable q12 "Ideology"

strrec Q13 ("Single, never married"=1)("Single, divorced"=2)("Separated"=3)("Living as an unmarried couple "=4)("Married"=5)("Widowed/Widower and not remarried"=6)("Widowed/Widower and remarried"=7)(.=.), sub generate(q13)
label variable q13 "Relationship Status"

strrec Q14 ("Living alone in my own home"=1)("Living in a household with other people"=2)("Living in a residential care facility"=3)("Temporarily staying with a friend or relative"=4)("Temporarily staying in a shelter or homeless"=5)(.=.), sub generate(q14)
label variable q14 "Living Situation"

strrec Q15 ("Agnostic"=1)("Atheist"=2)("Buddhist"=3)("Christian"=4)("Hindu"=5)("Jewish"=6)("Muslim"=7)("Other"=8)(.=.), sub generate(q15)
label variable q15 "Religion"


strrec Q16 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q16)
label variable q16 "Woman Should Devote Most Time to Family"
strrec Q17 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q17)
label variable q17 "Children Suffer if Mother Works for Pay"
strrec Q18 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q18)
label variable q18 "Children Suffer if Father Works for Pay"
strrec Q19 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q19)
label variable q19 "If Jobs are Scarce it Should be Men that Seek Work"
strrec Q20 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q20)
label variable q20 "Man Should be Primary Breadwinner"
strrec Q21 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q21)
label variable q21 "Women Call Attention to Themselves by the Way they Dress"
strrec Q22 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q22)
label variable q22 "There are Times it is Acceptable to Hit One's Partner"
strrec Q23 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q23)
label variable q23 "A Wife Should be able to Refuse Sex with Her Husband"
strrec Q24 ("Strongly disagree"=5)("Disagree"=4)("Neither agree nor disagree" = 3)("Agree"=2)("Strongly agree"=1)(.=.), sub generate(q24)
label variable q24 "A Man Cannot Rape His Own Wife"

*create scale from 13 (most anti-woman) to 45 (most pro-woman) on attitudes towards women then rescale to make 0-45 scale
gen q18b = q18
recode q18b (5=1) (4=2) (3=3) (2=4) (1=5) (.=.)
gen q23b = q23
recode q23b (5=1) (4=2) (3=3) (2=4) (1=5) (.=.)
egen womone = rowtotal (q16 q17 q18b q19 q20 q21 q22 q23b q24) 
gen womatt = womone - 9
sum womatt
label variable womatt "Attitudes Towards Women"



strrec Q25 ("True" = 1)("False"= 0) (.=.), sub generate(q25)
strrec Q26 ("True" = 1)("False"= 0) (.=.), sub generate(q26)
strrec Q27 ("True" = 1)("False"= 0) (.=.), sub generate(q27)
strrec Q28 ("True" = 1)("False"= 0) (.=.), sub generate(q28)
strrec Q29 ("True" = 1)("False"= 0) (.=.), sub generate(q29)
strrec Q30 ("True" = 1)("False"= 0) (.=.), sub generate(q30)
strrec Q31 ("True" = 1)("False"= 0) (.=.), sub generate(q31)
strrec Q32 ("True" = 1)("False"= 0) (.=.), sub generate(q32)
strrec Q33 ("True" = 1)("False"= 0) (.=.), sub generate(q33)
strrec Q34 ("True" = 1)("False"= 0) (.=.), sub generate(q34)
egen childcts = rowtotal(q25 q26 q27 q28 q29 q30 q31 q32 q33 q34)
label variable childcts "Child Conflict Tactics Scale"

strrec Q35 ("True" = 1)("False"= 0) (.=.), sub generate(q35)
strrec Q36 ("True" = 1)("False"= 0) (.=.), sub generate(q36)
strrec Q37 ("True" = 1)("False"= 0) (.=.), sub generate(q37)
strrec Q38 ("True" = 1)("False"= 0) (.=.), sub generate(q38)
strrec Q39 ("True" = 1)("False"= 0) (.=.), sub generate(q39)
strrec Q40 ("True" = 1)("False"= 0) (.=.), sub generate(q40)
strrec Q41 ("True" = 1)("False"= 0) (.=.), sub generate(q41)
strrec Q42 ("True" = 1)("False"= 0) (.=.), sub generate(q42)
strrec Q43 ("True" = 1)("False"= 0) (.=.), sub generate(q43)
strrec Q44 ("True" = 1)("False"= 0) (.=.), sub generate(q44)
egen adultcts = rowtotal(q35 q36 q37 q38 q39 q40 q41 q42 q43 q44)
label variable adultcts "Adult Conflict Tactics Scale"

gen cts = childcts+adultcts
label variable cts "Conflict Tactics Scale"

strrec Q45 ("True" = 1)("False"= 0) ("Prefer not to answer" = -999) (.=.), sub generate(q45)
label variable q45 "Counseling GBV"
strrec Q46 ("True" = 1)("False"= 0) ("Prefer not to answer" = -999) (.=.), sub generate(q46)
label variable q46 "Counseling Other Violence"
strrec Q47 ("True" = 1)("False"= 0) ("Prefer not to answer" = -999) (.=.), sub generate(q47)
label variable q47 "Taken Out Restraining Order"
strrec Q48 ("True" = 1)("False"= 0) ("Prefer not to answer" = -999) (.=.), sub generate(q48)
label variable q48 "Restraining Order Against Me"
strrec Q49 ("True" = 1)("False"= 0) ("Prefer not to answer" = -999) (.=.), sub generate(q49)
label variable q49 "Have Charged Someone with GBV"
strrec Q50 ("True" = 1)("False"= 0) ("Prefer not to answer" = -999) (.=.), sub generate(q50)
label variable q50 "Have Been Charged with GBV"
label define truefalse 1 "True" 0 "False" -999 "Prefer Not to Answer"
label values q45-q50 truefalse

*create versions of q45-q50 with only true false responses used
gen q45b = q45
recode q45b (1=1) (0=0) (-999=.) (.=.)
label variable q45b "rec Counseling GBV"
gen q46b = q46
recode q46b (1=1) (0=0) (-999=.) (.=.)
label variable q46b "rec Counseling Other Violence"
gen q47b = q47
recode q47b (1=1) (0=0) (-999=.) (.=.)
label variable q47b "rec Taken Out Restraining Order"
gen q48b = q48
recode q48b (1=1) (0=0) (-999=.) (.=.)
label variable q48b "rec Restraining Order Against Me"
gen q49b = q49
recode q49b (1=1) (0=0) (-999=.) (.=.)
label variable q49b "rec Have Charged Someone with GBV"
gen q50b = q50
recode q50b (1=1) (0=0) (-999=.) (.=.)
label variable q50b "Have Been Charged with GBV"
label values q45b-q50b truefalse


strrec Q51 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q51)
label variable q51 "Insulting Names"
strrec Q52 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q52)
label variable q52 "Withhold Food Water"
strrec Q53 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q53)
label variable q53 "Threaten Family"
strrec Q54 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q54)
label variable q54 "Can't Leave House"
strrec Q55 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q55)
label variable q55 "Threaten Shooting"
strrec Q56 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q56)
label variable q56 "Controlling Interactions"
strrec Q57 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q57)
label variable q57 "Beating, Bruising"
strrec Q58 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q58)
label variable q58 "Beating, Breaking"
strrec Q59 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q59)
label variable q59 "Sexual Humiliation"
strrec Q60 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q60)
label variable q60 "Intentional Injury via Sex"
strrec Q61 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q61)
label variable q61 "Raping"
strrec Q62 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q62)
label variable q62 "Drugging"
strrec Q63 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q63)
label variable q63 "Forced Household Labor"
strrec Q64 ("Neither"=0) ("Gender based violence"=1) ("Torture"=2) ("Both"=3) (.=.), sub generate(q64)
label variable q64 "Denying Medication"

label define singletorture 0 "Neither" 1 "Gender Based Violence" 2 "Torture" 3 "Both"
label values q51-q64 singletorture


strrec Treatment ("Control"=1) ("A"=2 "Expert Testimonial") ("B"=3 "Victim Testimonial"), sub generate(q65)
label define treatment 1 "Control" 2 "Expert Testimonial" 3 "Victim Testimonial"
label values q65 treatment

*Get rid of old form of variables

*drop Q3-Treatment

*Create dummies to indicate that respondent says "yes" about whether item is torture

gen q51tort = 0
replace q51tort = 1 if q51 > 1
replace q51tort = . if missing(q51)

gen q52tort = 0
replace q52tort = 1 if q52 > 1
replace q52tort = . if missing(q52)

gen q53tort = 0
replace q53tort = 1 if q53 > 1
replace q53tort = . if missing(q53)

gen q54tort = 0
replace q54tort = 1 if q54 > 1
replace q54tort = . if missing(q54)

gen q55tort = 0
replace q55tort = 1 if q55 > 1
replace q55tort = . if missing(q55)

gen q56tort = 0
replace q56tort = 1 if q56 > 1
replace q56tort = . if missing(q56)

gen q57tort = 0
replace q57tort = 1 if q57 > 1
replace q57tort = . if missing(q57)

gen q58tort = 0
replace q58tort = 1 if q58 > 1
replace q58tort = . if missing(q58)

gen q59tort = 0
replace q59tort = 1 if q59 > 1
replace q59tort = . if missing(q59)

gen q60tort = 0
replace q60tort = 1 if q60 > 1
replace q60tort = . if missing(q60)

gen q61tort = 0
replace q61tort = 1 if q61 > 1
replace q61tort = . if missing(q61)

gen q62tort = 0
replace q62tort = 1 if q62 > 1
replace q62tort = . if missing(q62)

gen q63tort = 0
replace q63tort = 1 if q63 > 1
replace q63tort = . if missing(q63)

gen q64tort = 0
replace q64tort = 1 if q64 > 1
replace q64tort = . if missing(q64)


*creating two-category gender variable to do ttest b/w male and female means on torture 
gen gen2 = q5
recode gen2 (1=.) (2=1) (3=2)


*create additive torture index 0-14

egen torture = rowtotal(q51tort q52tort q53tort q54tort q55tort q56tort q57tort q58tort q59tort q60tort q61tort q62tort q63tort q64tort)


*version of sex just male/female
gen q5b = q5
recode q5b (1=.)


